@extends('layouts.console_header')

@section('title', '收款账号管理修改')

@section('resources')
    @parent
    <style>
		.receivable_check{padding: 20px;background-color: #fff;}
		.receivable_check p{margin: 10px 0;}
		.receivable_check p .title_name{width: 120px;height: 30px;text-align: right;line-height: 30px;font-size: 18px;margin-right: 20px;}
		.receivable_check p span{height: 30px;line-height: 30px;font-size: 18px;}
		.receivable_check p input{width: 300px;border: 1px solid #000;height: 28px;padding: 0 5px;float: left;margin-right: 10px;}
    </style>
@endsection

@section('content')
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		    <span style="color: #7f7f7f;">首页>财务中心></span><span class="co_violet">收款账号管理修改</span>
        </p>
		<a onclick="history.go(-1);" href="#"><p class="fr tc back_btn">返回</p></a>
	</div>
	<form action="" method="" class="receivable_check">
	    <input type="hidden" name="shopid" value="{{$shopid}}">
	    <input type="hidden" name="cityid" value="{{$cityid}}">
		<p class="oh">
			<span class="fl title_name">商家代码</span>
			<span class="fl">{{$code}}</span>
		</p>
		<p class="oh">
			<span class="fl title_name">商家名称</span>
			<span class="fl">{{$name}}</span>
		</p>
		<p class="oh">
			<span class="fl title_name">门店登录账号</span>
			<span class="fl">{{$parentmobile}}</span>
		</p>
		<p class="oh">
			<span class="fl title_name">商务姓名</span>
			<span class="fl">{{$adminname}}</span>
		</p>
		<p class="oh">
			<span class="fl title_name">持卡人</span>
			<input type="text" name="cardholder" value="{{$cardholder}}">
		</p>
        <p class="oh">
            <span class="fl title_name">身份证号</span>
            <input class="fl" type="text" maxlength="18" name="idcard" value="{{$idcard}}">
        </p>
		<p class="oh">
			<span class="fl title_name">银行卡号</span>
			<input type="text" name="bankcard" value="{{$bankcard}}">
		</p>
		<p class="oh">
			<span class="fl title_name">银行名称</span>
			<input style="width: 100px;height: 30px;border-radius: 5px;" type="button" name="" value="查询" onclick="getbankname()" />
			<input type="text" name="bankname" id="bankname" value="{{$bankname}}" placeholder="请输入银行名称">
		</p>
		<p class="oh">
            <span class="fl title_name">开户行所在地</span>
            <input style="width: 100px;" type="text" name="bankprovince" value="{{$bankprovince}}" placeholder="省份">
            <input style="width: 100px;" type="text" name="bankcity" value="{{$bankcity}}" placeholder="城市">
        </p>
		<p class="oh">
            <span class="fl title_name">开户行名称</span>
            <input type="text" name="opencardbank" value="{{$opencardbank}}">
        </p>
        <div style="width: 1160px;margin: 20px 10px;" class="oh">
            <input class="sure fl" type="button" id="submit_data" style="background-color: #9955c6;" value="保存"/>
            <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
        </div>
	</form>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        var cityid = '{{$cityid}}';
        function getbankname(){
            var bankcard = $("input[name='bankcard']").val();
            if(bankcard == '') {
                alert('银行卡不能为空');
            }
            $.ajax({
                url : '/console/bankname/get',
                data:{"bankcard":bankcard},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var bankname = data.data;
                        $("input[name='bankname']").val(bankname);
                    }
                }
            });
        }
        $("#submit_data").click(function() {
            $.ajax({
                url : '/console/finance/receivable/update',
                data:$(".receivable_check").serialize(),
                type:'post',
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        alert(data.message);
                        window.location.href="/console/finance/receivable/manage?cityid="+cityid;
                    } else {
                        alert(data.message);
                    }
                }
            });
        });
    </script>
@endsection